﻿namespace Controllers
{
    using System;
    using System.Diagnostics;
    using Domains;
    using System.IO;

    /// <summary>
    /// Controller for merged file loading
    /// </summary>
    public static class LoadResultFileController
    {
        /// <summary>
        /// Method for load merged file to WebBrowser
        /// </summary>
        public static void Load(string previusVersion, string customVersion, string nextVersion)
        {
            ResultFile = AppDomain.CurrentDomain.BaseDirectory + @"ResultFile.xml";
            Execution.ExecMergeScript(customVersion, nextVersion, previusVersion, ResultFile);
        }

        #region Private Methods

        /// <summary>
        /// Converting string to html file
        /// </summary>
        /// <param name="str">The string wich contain all Html data</param>
        /// <param name="filename">The name of the html file</param>
        private static void StringToFile(string str, string filename)
        {
            StreamWriter NewStreamWriter = new StreamWriter(filename);
            NewStreamWriter.WriteLine(str);
            NewStreamWriter.Close();
        }

        #endregion

        #region Properties

        /// <summary>
        /// The hole path of file which will present in near WebBrowser Window
        /// It's a merged file from all 3 versions
        /// </summary>
        public static string ResultFile { get; set; }

        #endregion
    }
}
